A. Field of the Invention
The present invention relates generally to a graphics system for a personal computer. More particularly, the present invention relates to a graphics system for providing texture to images on a computer screen. Still more particularly, the present invention relates to an improvement in texture filtering techniques.
B. Background of the Invention
Before the availability of the personal computer (commonly referred to as a PC), computer graphics packages were expensive tools primarily reserved for industrial applications. Early microcomputers were only capable of rendering simple line drawings with a low screen resolution (256 pixels.times.256 pixels, for example). As microcomputers evolved, higher resolution color displays became available, and software applications routinely provided data output in a graphical format. The graphics techniques used were unstructured, with objects defined in terms of absolute coordinates using straight lines. Subsequently, graphics "primitives" were developed, enabling circles, ellipses, rectangles and polygons to be drawn with single software instructions. The use of primitives for drawing shapes increased the speed at which the images could be rendered.
The availability of computer graphics has generated a demand for higher resolutions and three dimensional (3-D) rendering capabilities. Computer animation and games, in particular, have spawned a revolution in computer graphics capabilities. A 3-D image can be represented in a computer system as a collection of graphical objects, such as polygons, lines, and points. A set of vertex points defines a polygon. Associated with each point are certain parameters, such as shading, texturing, color, and the like. Identification of other non-vertex points within the polygon typically is done through the use of linear interpolation. Once interpolated, the polygon can be rendered on a computer monitor by scanning of successive rows of the polygon. By drawing multiple polygons on the screen at a time, an object can be drawn.
Further advancements in the computer graphics arena have led to techniques for enhancing the realistic appearance of objects drawn on the screen. Texture mapping, one of the significant aspects of 3-D graphics, permits images on a computer screen to be displayed with texture. Thus, for example, a table top can be textured to have the appearance of a wood-grain or marble surface, or any other desired surface. In computer graphics, a texture map is an array of pixels that represents a particular pattern, such as a single brick. By repeatedly applying the texture map of a brick to side of a building, for example, the side will appear as a brick wall. The amount of memory required to represent the brick wall is minimal because only enough memory is required to store a texture map for a single brick.
A pixel in a texture map is called a "texel." A texture map typically is constructed from a two-dimensional array of texels (typically represented with digital values). A u, v address or coordinate is associated with each texel value in the texture map. Pixels on the computer screen, however, are assigned x, y coordinates or addresses to represent the spatial location of the pixel on the computer screen. Thus, a pixel with an address of (10, 14) would be in the tenth column of pixels, fourteen rows down from the top of the computer screen. Because texel values are not assigned an x, y value when applying a texture map to a polygon on the screen, a conversion from an x, y pixel address to a u, v texture map address is necessary. The conversion process is termed "texture mapping." A texture mapping algorithm thus uses an x, y pixel address to look up a corresponding texel in a texture map. The texel is then used to render the pixel at the x, y screen address.
Texture maps often are applied to objects that are a different shape and size from the texture map. For example, a texture may be expanded and applied to an object that is larger than the original texture map. Expanding a texture map to apply to an object, however, makes the resulting object appear blocky. To minimize this and related problems with applying texture maps to screen objects, graphics systems normally employ texture filtering techniques. Some of these filtering techniques are described below.
Ordinarily, an x, y pixel address converts to a fractional u, v texture map coordinate. A "10.16" format is typically used to represent the converted u and v coordinates in which 10 bits are used for the integer portion of the coordinate along with 16 fractional bits. The coordinates of texel values in a texel map, however, include only integer values, and thus the converted u, v coordinate usually will not map exactly to a texel in the texel map. Point sampling provides the simplest method for selecting a texel from a texel map for applying to objects. In point sampling, the texel from the texture map closest to the fractional u, v coordinate is selected to render the corresponding x, y pixel on the screen. For example and referring now to FIG. 1, four texels A, B, C, and D from a texture map are shown with their integer u, v coordinates. An address in x, y space might convert to u, v texture space as point P1 with u, v coordinates (0.25, 0.30). Of the four closest to texels A, B, C, and D, point P1 is closest to texel A. Using the point sampling technique, texel A would be selected to be mapped onto the x, y pixel. With point sampling, only one texel is used for each pixel during mapping and thus only one memory access is required to fetch the selected nearest texel. Although simple and fast, images rendered with point sampling may appear blocky and "scintillate," or sparkle, when the object moves detracting from the appearance of the object.
In certain instances, however, point sampled images are acceptable. For example, rendered with perspective, a brick wall may appear to recede into the distance. The appearance of the foreground part of the wall would suffer if point sampling was used because the texture map used may be "super sampled" meaning the same texel value will be used for a large group of pixels in the wall. However, the problems associated with super sampled point sampled images would be imperceptible if point sampling were used to texture the distant part of the wall because of the diminished resolution associated with objects drawn to appear distant. However, problems with subsampled textures may occur on the distant part of the wall as too few texels may be used from the texture map causing insufficient texture information to be used to give a realistic brick wall appearance.
Another filtering technique referred to as bilinear averaging results generally in higher quality texture images. Bilinear averaging combines the four nearest texels in a weighted average to derive a single texel value used to render the pixel. Referring again to FIG. 1, in the u axis point P1 is generally closer to texel A than texel B and closer to texel C than texel D. Thus, the bilinear weighted average of texels A, B, C, and D generally weights A more than B, and C more than D. In the v axis, the result is similar with texels A and B weighted more heavily than texels C and D because point P1 is closer to texels A and B than C and D. Bilinear averaged images achieve superior quality than point sampled images, but require more computer and processing power. Because four texels are averaged together, four accesses to texture memory are required to fetch the four texels, taking considerably more time than the single memory access required by point sampling. Further, the averaging process, including calculation of the weights associated with each texel to be averaged, requires time to perform.
Graphics systems that employ texturing typically use only one texture mapping technique at a time when rendering images. Thus, one graphics system might use point sampling for faster speed, while other systems might use bilinear averaging for higher quality. Both types of systems, however, suffer from the problems attendant to each texturing technique.
Another filtering technique described in commonly assigned and co-pending application "Dynamically Selectable Texture Filter For Computer Graphics," Ser. No. 08/831,283, filed Mar. 31, 1997, combines the speed advantage of point sampling with the quality advantage of bilinear averaging. In this technique, the texel array is divided into nine regions as shown in FIG. 2. The area surrounding the four texels A, B, C, D are divided into the nine regions labeled I-IX. In accordance with the preferred embodiment described in Ser. No. 08/831,283, the graphics processor uses the point sampling technique when a fractional texel coordinate corresponds to one of the four comer regions I, III, VII and IX. The graphics processor however, averages the two nearest texel values when the fractional u, v coordinate falls within one of the four side regions II, IV, VI, and VIII. Finally, the graphics processor computes a four texel average when the fractional texel coordinate falls within the center region V. This technique takes advantage of the speed benefit from point sampling when a fractional texel coordinate is close to one texel in a texture map, but also takes advantage of the quality improvements realized by using a two or four texel filtering technique when the fractional texel coordinate lies elsewhere.
Although the filtering techniques described above solve many of the short comings associated with texture mapping, these techniques may still be improved. Many images, such as a checkerboard 70 shown in FIG. 3, include high frequency components. The checkerboard 70 in FIG. 3 includes an array of alternating black squares 71 and white squares 73, although in general each square may include any color besides black and white. The transition 72 in color between black square 71 and white square 73 is very sharp, occurring over a range of one pixel. The sharp transition 72 corresponds to a high spatial frequency, as is well known. The filtering techniques described above represent low pass filters. A low pass filter passes only low spatial frequency components of an image, while attenuating or eliminating high spatial frequency components of the image. Because the checkerboard 70 in FIG. 3 includes both low spatial frequency components represented at the center of each square 71, 73, and high special frequency components represented by the sharp color transition 72 between squares, low pass filtering checkerboard 70 allows the low frequency components to pass through the filter unhindered, while attenuating or completely eliminating the high frequency transitions. The resulting filtered image may bare little resemblance to the checker board shown in FIG. 70 as the transitions between squares of color are blurred.
The filtering technique of co-pending application Ser. No. 08/831,283, filed Mar. 31, 1997 is now further described with reference to FIG. 4. The coordinates of two exemplary texels, texel A and texel B are shown along the horizontal axis which represents the texel coordinate. Unless otherwise stated, all texel coordinates refer to sub-texel coordinates in which each coordinate is defined relative to an adjacent texel. Referring to FIG. 2, for example, the sub-texel coordinates of texels B (1,0), C (0,1), and D (1,1) are defined relative to texel A which is assumed to have a sub-texel coordinate of (0, 0).
Referring to FIG. 4, the color value associated with texel A is shown as color A on the vertical axis and the color value associated with texel B is also shown on the vertical axis as color B. The sub-texel coordinates between texel A and texel B are divided into three ranges 52, 54, 56. These ranges correspond to regions I, II, and III, respectively, in FIG. 2. The preferred embodiment of this invention describes a graphics processor that employs the point sampling filtering technique when a texel coordinate is in regions 52 or 56. For sub-texel coordinates in range 52, the graphics processor uses only color A to render the pixel on the screen, and does not average colors A and B together. Similarly, the graphics processor uses only color B for sub-texel coordinates within range 56. In the intermediate range 54, the graphics processor computes a weighted average of the color A and color B values to produce a color value in the range 60. The weighted average is computed based on a scale factor determined as a percentage of the range between texels A and B corresponding to the sub-texel fractional coordinate. For example, if the sub-texel coordinate is exactly half way between texels A and B, then color A and color B are averaged evenly (i.e., scale factor equal to 0.5). If, however, the sub-texel coordinate corresponds to a value of 1/4 (i.e., 1/4 of the range between texel A and texel B and represented by coordinate 50), then the scale factor equals 1/4 and the weighted average is computed by combining 1/4 of color B with 3/4 of color A (color A*3/4+color B*1/4). The transitions between the point sampling regions 52, 56 and the weighted average region 58, represented by vertical lines 57, are abrupt and cause the bluriness or distortion described above with respect to the checkerboard 70.
Texture mapping techniques, such as point sampling and bilinear averaging for example, have advantages and disadvantages as discussed above. Point sampling is generally faster than bilinear averaging, but bilinear averaging generally produces higher quality images than images produced using point sampling. Current graphics systems typically only use one texture mapping technique. Thus, one system might use only point sampling to apply a texture map to an object on the screen, while another system might use bilinear averaging. The advantages current graphics systems enjoy, as well as the disadvantages such systems suffer, depend to a large extent on the particular texture mapping technique used. Generally, graphics systems designers tradeoff speed against quality; higher speed is achieved with point sampling and higher image quality is achieved with bilinear averaging.
Thus there is a need for an improved graphic system that allows texture maps with high frequency components, such as a checkerboard, to be applied to an object on the screen with as little distortion as possible. Such a system should preferably combine the speed advantages of point sampling with an improved multi-texel averaging technique to provide a graphics system that generates high quality images at faster speeds than previous graphics systems. Despite the advantages such a system would offer, to date no such system is known.